package message;

import model.RoomInfo;
import socket.ChessServer;

/**
 * 客户端悔棋报文.
 *
 * @author 张紘溢
 */
public class BackChessMessage extends BaseMessage {
    private int roomId;
    private boolean isLeft;

    public BackChessMessage(int roomId, boolean isLeft) {
        this.roomId = roomId;
        this.isLeft = isLeft;
    }

    @Override
    public void sendToServer() {
        RoomInfo roomInfo = ChessServer.getInstance().getRooms().get(roomId);
        if (isLeft) {//判断向哪边发送报文
            ServerBackChess serverBackChess = new ServerBackChess();
            ChessServer.getInstance().sendMsgToClient(serverBackChess, roomInfo.getRightPlayer());
        } else {
            ServerBackChess serverBackChess = new ServerBackChess();
            ChessServer.getInstance().sendMsgToClient(serverBackChess, roomInfo.getLeftPlayer());
        }
    }

    @Override
    public void selfExecute() {

    }
}
